//@ts-ignore
import request from '@/utils/request';
//@ts-ignore
import type {
    ResponseData,
    productQueryRequestData,
    DeleteRequest,
    productAddRequestData,
    productCommentAddRequestData,
    productCommentOrBuyRequestData,
    updateproductCountRequestData
} from '@/api/product/type';

/**
 * 商品接口集合
 */
enum API {
    ProductLIST_URL = '/product/list/page/sort',
   PRODUCTINFO_URL = '/product/get',
   PRODUCTPICLIST_URL = '/productpic/list',
   PRODUCTCOMMENTLIST_URL = '/productcomment/list',
   PRODUCTCOMMENTADD_URL = '/productcomment/add',
   DELETEPRODUCT_URL = '/product/delete',
   ADDPRODUCT_URL = '/product/add',
   ORBUYPRODUCT_URL = '/productcomment/orbuy',
    PRODUCTCOUNT_URL = '/product/updateproductCount',
}

export const reqProductList = (data: productQueryRequestData) =>
    request.post<any, ResponseData>(API.ProductLIST_URL, data)

export const reqProductInfo = (id: Number) =>
    request.get<any, ResponseData>(API.PRODUCTINFO_URL+`/?id=${id}`,)
export const reqProductPicListInfo = (id: Number) =>
    request.get<any, ResponseData>(API.PRODUCTPICLIST_URL+`/?id=${id}`,)
export const reqProductCommentListInfo = (id: Number) =>
    request.get<any, ResponseData>(API.PRODUCTCOMMENTLIST_URL+`/?id=${id}`,)

export const reqdELETEProduct = (data: DeleteRequest) =>
    request.post<any, ResponseData>(API.DELETEPRODUCT_URL, data)

export const reqAddProduct = (data: productAddRequestData) =>
    request.post<any, ResponseData>(API.ADDPRODUCT_URL, data)

export const reqAddProductComment = (data: productCommentAddRequestData) =>
    request.post<any, ResponseData>(API.PRODUCTCOMMENTADD_URL, data)

export const reqOrBuyProductComment = (data: productCommentOrBuyRequestData) =>
    request.post<any, ResponseData>(API.ORBUYPRODUCT_URL, data)

export const reqUpdateproductCountProduct = (data: updateproductCountRequestData) =>
    request.post<any, ResponseData>(API.PRODUCTCOUNT_URL, data)





